using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Runtime.Serialization;

namespace WSBanking.DAO
{
	#region using
	using System.Data;
	using WSBanking.DTO;
	using WSBanking.Helpers;
	#endregion

	/// <summary>
	/// Data access object, which get data of SEBanking_Card table from database
	/// </summary>
	public class SEBanking_CardDAO : AbstractDAO
	{
		public SEBanking_CardDAO(string strPath): base(strPath)
		{
		}

		public DataSet SelectByID(string card_id)
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_SEBanking_Card_SelectByID";
				base.InitializeCommand();
				base.AddParameter("@Card_ID", SqlDbType.NVarChar, 1000, card_id);
				base.FillDataSet(ref ds, "SEBanking_Card");
				return ds;
			}
			catch(System.Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			finally
			{
				base.CleanUpObject();
			}
			return null;
		}

        public bool Update(SEBanking_CardDTO obj)
        {
            try
            {
                base.sql = "usp_SEBanking_Card_Update";
                base.InitializeCommand();
                base.AddParameter("@Card_ID", SqlDbType.NVarChar, 1000, obj.Card_ID);
                base.AddParameter("@Card_SecurityCode", SqlDbType.NVarChar, 1000, obj.Card_SecurityCode);
                base.AddParameter("@Card_ExpirationDate", SqlDbType.DateTime, 1000, obj.Card_ExpirationDate);
                base.AddParameter("@Acc_ID", SqlDbType.NVarChar, 1000, obj.Acc_ID);
                base.AddParameter("@Card_Banlance", SqlDbType.NVarChar, 1000, obj.Card_Banlance);
                return ExecuteStoredProcedure();
            }
            catch
            {
                return false;
            }
        }
	}
}